package com.icss.controller;

import com.icss.dao.IUserDao;
import com.icss.entity.ClientUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class ClientController {
    @Autowired
    private IUserDao iUserDao;
//    登录
    @RequestMapping("ClientLogin")
    public  String  ClientFun01(String tel, String password, HttpSession session){
        ClientUser clientUser = iUserDao.ClienLogin(tel,password);
        System.out.println(clientUser);
        if (clientUser != null){
            session.setAttribute("clientUser",clientUser);
            return "good";
        }else {
            return null;
        }

    }
//      注册
    @RequestMapping("ClientRegister")
    public  String  ClientFun02(String username,String password,String password1,String tel,String pid){
        if (password.equalsIgnoreCase(password1)){
            ClientUser clientUser =new ClientUser();
            clientUser.setUsername(username);
            clientUser.setPassword(password);
            clientUser.setTel(tel);
            clientUser.setPid(pid);
            iUserDao.ClientRegister(clientUser);
            System.out.println(clientUser);
            return "index";
        }else {
            return "register";
        }


    }
}
